package kr.co.itatech.android;

import kr.co.itatech.android.*;
import kr.co.itatech.android.manager.*;
import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public abstract class BaseActivity extends Activity {
    public static final int PROC_OK = 0;
    
    
    /**통신 매니저*/
    private HttpManager httpMgr;
    /**리소스 매니저*/
    private ResourceManager resMgr;
    
    private Handler commonHandler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(createLayout());
        resMgr.getInstance(this);
    }

    public void buttonClick(View v){
        clickEvent(v.getId());
    }
    
    /**
     * 화면에 표시될 View
     * @return
     */
    public abstract int createLayout();
    
    /**
     * 화면에 표시될 View Initialize
     * @return
     */
    public abstract void initLayout();
    
    /**
     * 벨리데이션 체커
     * @return
     */
    public abstract int checkValue();
    
    /**
     * 다음화면 이동
     * @param class1
     * @return
     */
    public boolean goNextActivity(Class class1){
        int result = checkValue();
        if (result != PROC_OK) {
            Intent intent = new Intent(getApplicationContext(), class1);
            startActivity(intent);
            return true;
        }else {
            Toast.makeText(this, getString(result), Toast.LENGTH_SHORT).show();
        }
        return false;
    }

    /**
     * 버튼이벤트 받기
     * @param id
     */
    public abstract void clickEvent(int id);
    
    /**
     * 통신에 사용될 handler
     * @return
     */
    public Handler getCommonHandler() {
        return commonHandler;
    }

    /**
     * 통신에 사용될 handler
     * @return
     */
    public void setCommonHandler(Handler commonHandler) {
        this.commonHandler = commonHandler;
    }
}
